package nodes.command;

import java.awt.Point;
import java.util.List;
import parser.ParserException;
import model.Model;
import nodes.AbstractNode;
import nodes.ConstantNode;


/**
 * Returns the first active turtle's X-Coordinate
 */
public class XcorC extends AbstractCommand
{
    public AbstractNode evaluate (List<AbstractNode> myArguments, Model model)
    {
        if (myArguments.size() != Integer.parseInt(resources.getString("xcor")))
        {
            throw ParserException.BAD_ARGUMENTS;
        }

        Point location = model.getActiveTurtles().get(0).getLocation();

        return new ConstantNode((int) location.getX());
    }
}
